#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([bayer2rgb], [0.6.1], [Enrico Scholz <enrico.scholz@sigma-chemnitz.de>])
AM_INIT_AUTOMAKE([gnits dist-xz subdir-objects])
AM_MAINTAINER_MODE

AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_MACRO_DIR([m4])

# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
AC_PROG_LN_S
LT_INIT

## Set -Wl,-as-needed *before* listing the libraries
AC_MSG_CHECKING([whether to enable -Wl,-as-needed])
AC_ARG_ENABLE([as-needed],
  [AS_HELP_STRING([--disable-as-needed],
                  [do not build the library with -Wl,-as-needed])],
  [AS_CASE([$withval],
           [yes], [use_asneeded=yes],
           [no],  [use_asneeded=no],
           [AC_MSG_ERROR([invalid value with --enable-as-needed])])],
  [use_asneeded=yes])
AC_MSG_RESULT([$use_asneeded])
AS_IF([test x"$use_asneeded" = xyes],[
  # This is hacky and might break with future libtool versions.
  # Missing -Wl,-as-needed feature for dynamic library exists for
  # ages, so apply this workaround
  lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -Wl,-as-needed"
])

## the 'dumb' conversion is implemented by C++ templates
AC_MSG_CHECKING([whether to enable C++ parts])
AC_ARG_ENABLE([cplusplus],
  [AS_HELP_STRING([--disable-cplusplus],[disable the C++ parts])],
  [AS_CASE([$withval],
           [yes], [use_cplusplus=yes],
           [no],  [use_cplusplus=no],
           [AC_MSG_ERROR([invalid value with --enable-cplusplus])])],
  [use_cplusplus=yes])
AC_MSG_RESULT([$use_cplusplus])
AM_CONDITIONAL([HAVE_CPLUSPLUS],[test x"$use_cplusplus" = xyes])

AC_MSG_CHECKING([whether to enable optional C parts])
AC_ARG_ENABLE([c],
  [AS_HELP_STRING([--disable-optional-c],[disable the optional C parts])],
  [AS_CASE([$withval],
           [yes], [use_opt_c=yes],
           [no],  [use_opt_c=no],
           [AC_MSG_ERROR([invalid value with --enable-optional-c])])],
  [use_opt_c=yes])
AC_MSG_RESULT([$use_opt_c])
AM_CONDITIONAL([HAVE_OPT_C],[test x"$use_opt_c" = xyes])

AC_CHECK_PROGS([GENGETOPT], [gengetopt])
AS_IF([test -z "$GENGETOPT"],
      [AC_MSG_ERROR([GNU gengetopt is required but could not be found])])
AC_CHECK_PROGS([GIT], [git])

# Checks for libraries.

: ${CFLAGS:=-Werror -pedantic -O3 -g3}

# Checks for header files.
AC_CHECK_HEADERS([asm/cachectl.h arm_neon.h])

AM_CONDITIONAL([HAVE_NEON],[test x"$ac_cv_header_arm_neon_h" = xyes])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile bayer2rgb3.pc])
AC_OUTPUT
